<include file="Public:header" />
{:W('Navigation')}
<div class="body-right">
	<div class="row-table">
		<div class="row-table-title">员工列表</div>
		<div class="row-table-body">
			<p class="form-title">
				<div class="pull-right">
					<a class="btn btn-primary" href="{:U('core/user/output')}" target="_blank">导出在职员工</a>
					<a class="btn btn-primary" href="{:U('core/user/output')}&status=2" target="_blank">导出离职员工</a>
					<a class="btn btn-primary btn-xs" href="{:U('core/user/adduser')}">添加员工</a>
				</div>
				
				<if condition="$searchs">
					<div class="col-sm-2">搜索“<if condition="$searchs.team">【{$searchs.team}】</if><span class="color-red">{$searchs.nickname}</span>”的用户列表</div>
				<else />
				
				<volist name="status_array" id="vo">
				<if condition="$key == $status">{$vo}&nbsp;&nbsp;&nbsp;<else /><a href='{:U("core/user/index","status=$key")}'>{$vo}</a>&nbsp;&nbsp;&nbsp;</if>
				</volist>
				
				</if>
				<form action="{:U("core/user/index")}" method="post" class="form-inline">
					<div class="form-group col-sm-2">
				    	<label for="name">团队选择：</label>
				    		<select name="dep" class="form-control">
				    			<option value="">请选择团队</option>
				    			<volist name="dep" id="vo">
				    				<option value="{$vo.department_id}">{$vo.name}</option>
				    			</volist>
				    		</select>
				    </div>
					<div class="input-group col-sm-2">
				      <div class="input-group-addon">姓名查询：</div>
				      <input type="text" class="form-control" name="nickname" placeholder="请输入姓名">
				    </div>
				    <button type="submit" class="btn btn-info">查询</button>
			    </form>
			    
			    
			</p>
			<table class="table table-hover table-striped" style="margin-bottom:0px;">
				<tbody>
					<tr>
						<if condition="$searchs"><th>员工状态</th></if>
						<th>姓名</th>
						<!--<th>性别</th>-->
						<th>部门 </th>
						<th>职务</th>
						<th>员工状态</th><!--
						<th>员工类型</th>-->
						<!--<th>保险情况</th>-->
						<th>手机</th>
						<th>银行卡号</th>
						<th>身份证</th>
						<th>操作</th>
						<th>人事审核</th>
					</tr>
					<volist name="userlist" id="vo">
					<tr>
						<if condition="$searchs">
							<td><if condition="$vo['status'] == 0">未激活<elseif condition="$vo['status'] == 1" />在职<elseif condition="$vo['status'] == 2" />离职<else />退休</if></td>
						
						</if>
						<td><a href="javascrip:;" onclick="getuser('{$vo.name}')">{$vo.nickname}</a></td>
						<!--<td><if condition="$vo['sex'] == 1">男<elseif condition="$vo['sex'] == 2" />女<else />未知</if></td>-->
						<td>{$vo.dep}</td>
						<td>{$vo.position_name}</td>
						<!--<td><if condition="$vo['status'] == 0">未激活<elseif condition="$vo['status'] == 1" />在职<elseif condition="$vo['status'] == 2" />离职<else />退休</if></td>
						<td><if condition="$vo['type'] == 0">试用期<elseif condition="$vo['type'] == 1" />正式工<elseif condition="$vo['type'] == 2" />临时工<else />其他</if></td>
						<td>
							<if condition="$vo['work_status'] == 0">
								正常
							<elseif condition="$vo['work_status'] == 1" />
								休假
							<elseif condition="$vo['work_status'] == 2" />
								出差
							<elseif condition="$vo['work_status'] == 3" />
								请假
							<elseif condition="$vo['work_status'] == 4" />
								调休
							</if>
						</td>-->
						<td><switch name="vo.type">
							<case value="0">试用期</case>
							<case value="1">正式工</case>
							<case value="2">临时工</case>
						</switch></td>
						<!--<td><if condition="$vo.baoxian eq 1">已买<else />未买</if></td>-->
						<td>{$vo.telephone}</td>
						<td>{$vo.bankcard}</td>
						<td>{$vo.sfzid}</td>
						<td>
							<a href="{:U('core/user/editinfo','id='.$vo['user_id'])}">编辑</a><!--&nbsp;|&nbsp;
							<a href="{:U('hrm/peibei/view','uid='.$vo['user_id'])}">配备</a>&nbsp;|&nbsp;
							<a href="{:U('hrm/staffcontract/index','user_id='.$vo['user_id'])}">人事合同</a>&nbsp;|&nbsp;
							<a href="{:U('hrm/archives/view','user_id='.$vo['user_id'])}">人事档案</a>&nbsp;|&nbsp;
							<a href="javascript:void(0);" class="punch_in" rel="{$vo.user_id}" value="0">上班打卡</a>&nbsp;|&nbsp;
							<a href="javascript:void(0);" class="punch_out" rel="{$vo.user_id}" value="1">下班打卡</a>-->
						</td>
						<td>
							<switch name="vo.v_status.status">
								<case value="0">
									<a href="javasctip:;" class="glyphicon glyphicon-remove-sign color-red"><?php
											switch($vo['v_status']['type']){
												case "add":
													echo "新添加";
													break;
												case "edit":
													echo "编辑";
													break;
											}
										?>未审核</a>
								</case>
								<case value="1">
									<span class="text-primary glyphicon glyphicon-ok-sign"><?php

											switch($vo['v_status']['type']){
												case "add":
													echo "新添加";
													break;
												case "edit":
													echo "编辑";
													break;
											}
										?>通过审核
									</span>
								</case>
								<case value="2">
									
									<span class="popovers btn btn-sm btn-danger glyphicon glyphicon-remove-sign" title="拒审原因！" data-container="body" data-toggle="popover" role="button" data-trigger="focus"  data-placement="right" data-content="<if condition="$vo['v_status']['msg_back'] eq ''">未填写拒审原因！<else />{$vo.v_status.msg_back}</if>"><?php

											switch($vo['v_status']['type']){
												case "add":
													echo "新添加";
													break;
												case "edit":
													echo "编辑";
													break;
											}
										?>已拒审</span>
								</case>
							</switch>
						</td>
					</tr>
					</volist>
				</tbody>
				<tfoot>
					<tr>
						<td colspan="9">{$page}<div class="clear"></div></td>
					</tr>
				</tfoot>
			</table>
		</div>
	</div>
</div>
<div class="clear"></div>
<script type="text/javascript">

	function getuser(uname){	
		$('#alert').modal({
			show:true,
			remote:'{:u("core/verify/view")}'+'&uname='+uname+"&user_id=1"
		});
	}
	
	/**
	 * Ajax上班打卡
	 * 
	**/
	$('.punch_in').click(function(){
		var user_id = $(this).attr('rel');
		var punch_type = $(this).attr('value');

		$.ajax({
			type: "POST",
			dataType: "JSON",
			url: "{:U('hrm/punch/add')}",
			data: {user_id : user_id, punch_type : punch_type},
			success: function (data) {
				alert(data.info);
			},
			error: function(data) {
				alert(data.info);
			}
		});
	});
	
	/**
	 * Ajax下班打卡
	 * 
	**/
	$('.punch_out').click(function(){
		var user_id = $(this).attr('rel');
		var punch_type = $(this).attr('value');

		$.ajax({
			type: "POST",
			dataType: "JSON",
			url: "{:U('hrm/punch/add')}",
			data: {user_id : user_id, punch_type : punch_type},
			success: function (data) {
				alert(data.info);
			},
			error: function(data) {
				alert(data.info);
			}
		});
	});
	$(function () {
		$('body').click(function(){
			$(".popovers .table-hover").popover('destroy');
		});
	  	$(".popovers").hover(function(){
		  	$(".popovers .table-hover").popover('destroy');
		  	$(this).popover('show');
	  });
	  
	})
</script>
<include file="Public:alert" />

<include file="Public:footer" />